﻿
/// <reference path="jquery-1.5.1-vsdoc.js" />

////////////////////// ////////// HGO GroupBox Start Code ///////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////

(function ($) {

  var $t = $.telerik;

  $t.hgogroupbox = function (element, options) {
    $.extend(this, options);

    this.element = element;
    var $element = this.$element = $(element);
    this.elementId = $element.attr("id");

    // Div 'in css sınıfı adv-window olmalı.
    $element.attr('class', 'adv-groupbox');

    // Width ve Height değerleri set edilir...
    $element.css('width', this.wndWidth);
    $element.css('height', this.wndHeight);

    // Header
    var header = this.header = $element.find('.adv-groupbox-header').get(0);

    // Content
    var content = this.content = $element.find('.adv-groupbox-content').get(0);

    // Eğer Content var ve değiştirilmek isteniyor ise...
    if ($(content).children().length === 0)
      $(content).html(this.contentWindow);

    var $title = this.$title = $('#' + this.elementId + ' .adv-groupbox-header label');

    // Eğer Title var ve değiştirilmek isteniyor ise...
    if ((this.titleWindow !== '') && (this.titleWindow !== null) && (typeof (this.titleWindow) !== 'undefined'))
      $title.text(this.titleWindow);

    this.$wrapper = $element;

    this[this.enabled ? 'enable' : 'disable']();
  }

  $t.hgogroupbox.prototype =
  {
    hide: function () {
      var wrapper = this.$wrapper;
      wrapper.hide();
    },

    show: function () {
      var wrapper = this.$wrapper;
      wrapper.show();
    },

    _update: function (text) {
      this._text(val);
    },

    _title: function (captionstr) {
      this.$title.text(captionstr);
    },

    enable: function () {
      this.enabled = true;
      this.$element.css("color", this.enableFontColor);
      this.$wrapper.removeClass('t-state-disabled');
    },

    disable: function () {
      this.enabled = false;
      this.$element.css("color", this.disableFontColor);
      this.$wrapper.addClass('t-state-disabled');
    },

    title: function (captionstr) {
      if (typeof (captionstr) === 'undefined' || captionstr === null)
        return this.$title.text();

      this._title(captionstr);
    },

    // Width set etme...
    width: function (value) {
      if (typeof (value) === 'undefined' || value === null)
        return this.$element.css('width');

      this.$element.css.width('width', value);
    },

    // Height set etme...
    height: function (value) {
      if (typeof (value) === 'undefined' || value === null)
        return this.$element.css('height');

      this.$element.css.height('height', value);
    }
  }

  $.fn.tHGOGroupBox = function (options) {
    var type = 'hgogroupbox';
    var defaults = $.fn.tHGOGroupBox.defaults[type];
    options = $.extend({}, defaults, options);
    options.type = type;

    return this.each(
                      function () {
                        var $element = $(this);
                        options = $.meta ? $.extend({}, options, $element.data()) : options;

                        if (!$element.data('tHGOGroupBox')) {
                          $element.data('tHGOGroupBox', new $t.hgogroupbox(this, options));
                          $t.trigger(this, 'load');
                        }
                      }
                    );
  };

  var commonDefaults =
  {
    titleWindow: 'GroupBox',
    contentWindow: '<div class="firstRow" style="vertical-align:middle;"> </div>',
    enabled: true,
    // Window Width And Height...
    wndWidth: 200,  // Sample Value
    wndHeight: 100  // Sample Value
  };

  $.fn.tHGOGroupBox.defaults = {
    hgogroupbox: $.extend(commonDefaults,
                                        {
                                          prop1: ''
                                        }
                          )
  };

})(jQuery);


// $('#HGOGroupBox').data('tHGOGroupBox').height(250)
// $('#HGOGroupBox').data('tHGOGroupBox').disable()
// $('#HGOGroupBox').data('tHGOGroupBox').enable()
// $('#HGOGroupBox').data('tHGOGroupBox').title('New Department 2')

